package com.example.mp.inject;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.SqlSource;

/**
 * @auther liujb
 * @date 2021/7/24-22:27
 */
public class DeleteAll  extends AbstractMethod {
    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
        // super.injectMappedStatement(mapperClass,modelClass,tableInfo);
        //注意: 此方法名要和你自己的mapper中一致
        String methodName = "removeAll";
        // 注入的sql语句
        String sql = "delete from " + tableInfo.getTableName();
        // 勾走sqlSource对象
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, Object.class);
        //构造一个删除的MappedStatement
        return this.addDeleteMappedStatement(mapperClass, methodName, sqlSource);
    }
}
